//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "PiecewiseConstantAbcdVariance.h"
using namespace Cephei::QL::Models::Marketmodels::Models;
#include <gen/QL/Models/Marketmodels/Models/PiecewiseConstantVariance.h>
#undef HANDLE
#undef ABSTRACT
#define STRUCT
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::CPiecewiseConstantAbcdVariance (Double a, Double b, Double c, Double d, UInt64 resetIndex, Cephei::Core::IVector<Double>^ rateTimes) : CPiecewiseConstantVariance(CPiecewiseConstantAbcdVariance::typeid)
{
    try
    {
#ifdef HANDLE
        _phPiecewiseConstantAbcdVariance = NULL;
#endif
        QuantLib::Real _a = (QuantLib::Real)ValueHelper::Convert (a); //d
        QuantLib::Real _b = (QuantLib::Real)ValueHelper::Convert (b); //d
        QuantLib::Real _c = (QuantLib::Real)ValueHelper::Convert (c); //d
        QuantLib::Real _d = (QuantLib::Real)ValueHelper::Convert (d); //d
        QuantLib::Size _resetIndex = (QuantLib::Size)ValueHelper::Convert (resetIndex); //d
        rateTimes->Lock();
        INativeVector<Double>^ _NCIrateTimes = rateTimes->getFeature (NativeFeature::Value);
        CDoubleVector^ _NCrateTimes = safe_cast<CDoubleVector^>(_NCIrateTimes);
        std::vector<QuantLib::Time>& _rateTimes = static_cast<std::vector<QuantLib::Time>&> (_NCrateTimes->GetReference ());
        _ppPiecewiseConstantAbcdVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance> (new QuantLib::PiecewiseConstantAbcdVariance ( _a,  _b,  _c,  _d,  _resetIndex,  _rateTimes ));
        SetPiecewiseConstantVariance (boost::dynamic_pointer_cast<QuantLib::PiecewiseConstantVariance> (*_ppPiecewiseConstantAbcdVariance));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (rateTimes != nullptr) rateTimes->Unlock();    //not optional
    }
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::CPiecewiseConstantAbcdVariance (boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>& childNative, Object^ owner) : CPiecewiseConstantVariance(CPiecewiseConstantAbcdVariance::typeid)
{
#ifdef HANDLE
	_phPiecewiseConstantAbcdVariance = NULL;
#endif
	_ppPiecewiseConstantAbcdVariance = &childNative;
    _ppPiecewiseConstantVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantVariance> (boost::dynamic_pointer_cast<QuantLib::PiecewiseConstantVariance> (*_ppPiecewiseConstantAbcdVariance));
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::CPiecewiseConstantAbcdVariance (QuantLib::PiecewiseConstantAbcdVariance& childNative, Object^ owner) : CPiecewiseConstantVariance(CPiecewiseConstantAbcdVariance::typeid)
{
#ifdef HANDLE
	_phPiecewiseConstantAbcdVariance = NULL;
#endif
	_ppPiecewiseConstantAbcdVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance> (&childNative);
    _ppPiecewiseConstantVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantVariance> (boost::dynamic_pointer_cast<QuantLib::PiecewiseConstantVariance> (*_ppPiecewiseConstantAbcdVariance));
    _PiecewiseConstantAbcdVarianceOwner = owner;
    _PiecewiseConstantVarianceOwner = owner;
}

Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::CPiecewiseConstantAbcdVariance (CPiecewiseConstantAbcdVariance^ copy) : CPiecewiseConstantVariance(CPiecewiseConstantAbcdVariance::typeid)
{
#ifdef HANDLE
	_phPiecewiseConstantAbcdVariance = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppPiecewiseConstantAbcdVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance> (copy->GetShared());
        _ppPiecewiseConstantVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantVariance> (boost::dynamic_pointer_cast<QuantLib::PiecewiseConstantVariance> (*_ppPiecewiseConstantAbcdVariance));
    }
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::CPiecewiseConstantAbcdVariance (PLATFORM::Type^ t) : CPiecewiseConstantVariance(CPiecewiseConstantAbcdVariance::typeid)
{
#ifdef HANDLE
	_phPiecewiseConstantAbcdVariance = NULL;
#endif
	if (!t->IsSubclassOf(CPiecewiseConstantAbcdVariance::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::CPiecewiseConstantAbcdVariance (QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>& childNative, Object^ owner)  : CPiecewiseConstantVariance(CPiecewiseConstantAbcdVariance::typeid)
{
	_phPiecewiseConstantAbcdVariance = &childNative;
	_ppPiecewiseConstantAbcdVariance = &static_cast<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>>(childNative.currentLink());
    _ppPiecewiseConstantVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantVariance> (boost::dynamic_pointer_cast<QuantLib::PiecewiseConstantVariance> (*_ppPiecewiseConstantAbcdVariance));
    _PiecewiseConstantAbcdVarianceOwner = owner;
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::CPiecewiseConstantAbcdVariance (QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance> childNative)  : CPiecewiseConstantVariance(CPiecewiseConstantAbcdVariance::typeid)
{
	_phPiecewiseConstantAbcdVariance = &childNative;
	_ppPiecewiseConstantAbcdVariance = &static_cast<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>>(childNative.currentLink());
    _ppPiecewiseConstantVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantVariance> (boost::dynamic_pointer_cast<QuantLib::PiecewiseConstantVariance> (*_ppPiecewiseConstantAbcdVariance));
}
#endif
#ifdef STRUCT
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::CPiecewiseConstantAbcdVariance (QuantLib::PiecewiseConstantAbcdVariance childNative)  : CPiecewiseConstantVariance(CPiecewiseConstantAbcdVariance::typeid)
{
#ifdef HANDLE
	_phPiecewiseConstantAbcdVariance = NULL;
#endif
	_ppPiecewiseConstantAbcdVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance> (new QuantLib::PiecewiseConstantAbcdVariance (childNative));
    _ppPiecewiseConstantVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantVariance> (boost::dynamic_pointer_cast<QuantLib::PiecewiseConstantVariance> (*_ppPiecewiseConstantAbcdVariance));
}
#endif

Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::~CPiecewiseConstantAbcdVariance ()
{
    if (_ppPiecewiseConstantAbcdVariance != NULL)
    {
	    delete _ppPiecewiseConstantAbcdVariance;
        _ppPiecewiseConstantAbcdVariance = NULL;
    }
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::!CPiecewiseConstantAbcdVariance ()
{
    if (_ppPiecewiseConstantAbcdVariance != NULL)
    {
	    delete _ppPiecewiseConstantAbcdVariance;
    }
}
QuantLib::PiecewiseConstantAbcdVariance& Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::GetReference ()
{
    if (_ppPiecewiseConstantAbcdVariance == NULL) throw REFNEW NativeNullException ();
	return **_ppPiecewiseConstantAbcdVariance;
}
boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>& Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::GetShared ()
{
    if (_ppPiecewiseConstantAbcdVariance == NULL) throw REFNEW NativeNullException ();
	return *_ppPiecewiseConstantAbcdVariance;
}
QuantLib::PiecewiseConstantAbcdVariance* Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::GetPointer ()
{
    if (_ppPiecewiseConstantAbcdVariance == NULL) throw REFNEW NativeNullException ();
	return &**_ppPiecewiseConstantAbcdVariance;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>& Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::GetHandle ()
{
	if (_phPiecewiseConstantAbcdVariance == NULL)
	{
		_phPiecewiseConstantAbcdVariance = new Handle<QuantLib::PiecewiseConstantAbcdVariance> (*_ppPiecewiseConstantAbcdVariance);
	}
	return *_phPiecewiseConstantAbcdVariance;
}
#endif
bool Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::HasNative () 
{
	return (_ppPiecewiseConstantAbcdVariance != NULL);
}

Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::GetABCD (Double a, Double b, Double c, Double d)
{
    try
    {
        QuantLib::Real _a = (QuantLib::Real)ValueHelper::Convert (a); //a
        QuantLib::Real _b = (QuantLib::Real)ValueHelper::Convert (b); //a
        QuantLib::Real _c = (QuantLib::Real)ValueHelper::Convert (c); //a
        QuantLib::Real _d = (QuantLib::Real)ValueHelper::Convert (d); //a
    	(*_ppPiecewiseConstantAbcdVariance)->getABCD ( _a,  _b,  _c,  _d );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Double>^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::RateTimes::get ()
{
    try
    {
    	std::vector<QuantLib::Time>& _rv = (std::vector<QuantLib::Time>&)(*_ppPiecewiseConstantAbcdVariance)->rateTimes ( );   
        Cephei::Core::IVector<Double>^ _nrv = REFNEW CoVector<Double> (REFNEW CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Double>^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::Variances::get ()
{
    try
    {
    	std::vector<QuantLib::Real>& _rv = (std::vector<QuantLib::Real>&)(*_ppPiecewiseConstantAbcdVariance)->variances ( );   
        Cephei::Core::IVector<Double>^ _nrv = REFNEW CoVector<Double> (REFNEW CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Double>^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance::Volatilities::get ()
{
    try
    {
    	std::vector<QuantLib::Real>& _rv = (std::vector<QuantLib::Real>&)(*_ppPiecewiseConstantAbcdVariance)->volatilities ( );   
        Cephei::Core::IVector<Double>^ _nrv = REFNEW CoVector<Double> (REFNEW CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::CPiecewiseConstantAbcdVarianceVector ()
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::~CPiecewiseConstantAbcdVarianceVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
	_pVValue = NULL;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
	_pVBoost = NULL;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
	_pVHand = NULL;
#endif
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::!CPiecewiseConstantAbcdVarianceVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
#endif
}
#ifdef STRUCT
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::CPiecewiseConstantAbcdVarianceVector (std::vector<QuantLib::PiecewiseConstantAbcdVariance>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = &vec;
	_owner = owner;
}
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::CPiecewiseConstantAbcdVarianceVector (std::vector<QuantLib::PiecewiseConstantAbcdVariance> vec)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = new std::vector<QuantLib::PiecewiseConstantAbcdVariance> (vec);
}
#endif
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::CPiecewiseConstantAbcdVarianceVector (std::vector<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVBoost = &vec;
	_owner = owner;
}
#ifdef HANDLE
Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::CPiecewiseConstantAbcdVarianceVector (std::vector<QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVHand = &vec;
	_owner = owner;
}
#endif

int Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::Count::get ()
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
		return _pVValue->size();
	}
#endif    
	if (_pVBoost != NULL)
	{
		return _pVBoost->size ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		return _pVHand->size ();
	}
#endif
	return 0;		// should never happen
}
Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::default::get (int index) 
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
    	if ((size_t)index >= _pVValue->size()) throw REFNEW RangeException ();
		QuantLib::PiecewiseConstantAbcdVariance& native = (*_pVValue)[index];
		return REFNEW CPiecewiseConstantAbcdVariance (native, this);
	}
#endif    
	if (_pVBoost != NULL)
	{
    	if ((size_t)index >= _pVBoost->size()) throw REFNEW RangeException ();
		QuantLib::PiecewiseConstantAbcdVariance& native = *(*_pVBoost)[index];
		return REFNEW CPiecewiseConstantAbcdVariance (native, this);
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
    	if ((size_t)index >= _pVHand->size()) throw REFNEW RangeException ();
		QuantLib::PiecewiseConstantAbcdVariance& native = *((*_pVHand)[index].currentLink ());
		return REFNEW CPiecewiseConstantAbcdVariance (native, this);
	}
#endif
	return nullptr;		// can never be the case
}
void Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::default::set (int index, Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^ value) 
{
#ifdef STRUCT
	if (_pVValue != NULL)
	{
		if (_pVValue->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVValue->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVValue->push_back (dynamic_cast<CPiecewiseConstantAbcdVariance^>(value)->GetReference ());
		}
        else
        {
            QuantLib::PiecewiseConstantAbcdVariance& c = (*_pVValue)[index];
            c = dynamic_cast<CPiecewiseConstantAbcdVariance^>(value)->GetReference ();
        }
	}
#endif   
	if (_pVBoost != NULL)
	{
		if (_pVBoost->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVBoost->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVBoost->push_back (dynamic_cast<CPiecewiseConstantAbcdVariance^>(value)->GetShared ());
		}
		boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>& c = (*_pVBoost)[index];
		c = dynamic_cast<CPiecewiseConstantAbcdVariance^>(value)->GetShared ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		if (_pVHand->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVHand->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVHand->push_back (QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance> ());
		}
		QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>& c = (*_pVHand)[index];
		boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>& b = static_cast<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>>(c.currentLink());
		b = dynamic_cast<CPiecewiseConstantAbcdVariance^>(value)->GetShared ();
	}
#endif
}
Cephei::Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::CItem::get (int index) 
{
	return CellFactory::Instance->Create<IPiecewiseConstantAbcdVariance^> (dynamic_cast<IPiecewiseConstantAbcdVariance^>(default[index]));
}

void Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::CItem::set (int index, Cephei::Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^ value) 
{
	default[index] = safe_cast<IPiecewiseConstantAbcdVariance^>(value->Value);
}
#ifdef STRUCT
std::vector<QuantLib::PiecewiseConstantAbcdVariance>& Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::GetReference ()
{
	 return *_pVValue;
}
#endif

std::vector<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>>& Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::GetShared ()
{
	return *_pVBoost;
}

#ifdef HANDLE
std::vector<QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>>& Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::GetHandle ()
{
	return *_pVHand;
}
#endif
bool Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVarianceVector::PrepareFeature (NativeFeature feature)
{
	switch (feature)
	{
#ifdef STRUCT
		case NativeFeature::Value :
			if (_pVValue == NULL)
			{
				_pVValue = new std::vector<QuantLib::PiecewiseConstantAbcdVariance> ();
				return true;
			}
			break;
#endif
        case NativeFeature::shared_ptr :
			if (_pVBoost == NULL)
			{
				_pVBoost = new std::vector<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>> ();
				return true;
			}
			break;
#ifdef HANDLE
        case NativeFeature::Handle :
            if (_pVHand == NULL)
            {
                _pVHand = new std::vector<QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>> ();
                return true;
            }
            break;
#endif
	}
	return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance_Factory::Create (Double a, Double b, Double c, Double d, UInt64 resetIndex, Cephei::Core::IVector<Double>^ rateTimes)
{
    return REFNEW CPiecewiseConstantAbcdVariance ( a,  b,  c,  d,  resetIndex,  rateTimes);
}
/* <summary>Create a single dimension array of PiecewiseConstantAbcdVariance that can be passed into other function </summary> */
IVector<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance_Factory::CreateVector ()
 {
	 return REFNEW CoVector<IPiecewiseConstantAbcdVariance^> (REFNEW CPiecewiseConstantAbcdVarianceVector ());
 }
IVector<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance_Factory::CreateVector (PLATFORM::Collections::Generic::IEnumerable<IPiecewiseConstantAbcdVariance^>^ source)
 {
	 return REFNEW CoVector<IPiecewiseConstantAbcdVariance^> (source, REFNEW CPiecewiseConstantAbcdVarianceVector ());
 }
/* <summary>Create a single dimension array of PiecewiseConstantAbcdVariance with change events</summary> */
Cephei::Core::Generic::ICoCell<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^>^>^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance_Factory::CreateCellVector ()
 {
	 return CellFactory::Instance->Create<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^>^> (REFNEW CoCellVector<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^> (REFNEW CPiecewiseConstantAbcdVarianceVector ()));
 }
Cephei::Core::Generic::ICoCell<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^>^>^ Cephei::QL::Models::Marketmodels::Models::CPiecewiseConstantAbcdVariance_Factory::CreateCellVector (PLATFORM::Collections::Generic::IEnumerable<Cephei::Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^>^ source)
 {
	 return CellFactory::Instance->Create<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^>^> (REFNEW CoCellVector<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^> (source, REFNEW CPiecewiseConstantAbcdVarianceVector ()));
 }

